{% extends 'admin/base.html' %}
{% block title %}爬虫代码{% endblock %}
{% block content %}
    <link rel="stylesheet" href="{{ url_for('static', filename='css/highlight-theme.css') }}">
    <pre><code id="code" class="rounded-lg"></code></pre>
{% endblock %}
{% block js %}
    <script src="{{ url_for('static', filename='js/highlight.js') }}"></script>
    <script>
        function getSpiderCode() {
            fetch('{{ url_for('admin.spider_code') }}', {method: 'POST'}).then(res => res.text()).then(data => {
                let code = hljs.highlight(data, {language: "python"})
                let codeDom = document.getElementById('code')
                codeDom.classList.add('hljs', `language-${code.language}`)
                codeDom.innerHTML = code.value
            })
        }
        onload_list.push(getSpiderCode)
    </script>
{% endblock %}